package com.glamour.hlcity.component.framework.factory;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import com.glamour.hlcity.component.framework.obse.ObserverListener;


public class FrameworkFactory implements ApplicationContextAware {
	
	private ApplicationContext applicationContext;

	@Override
	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		this.applicationContext=applicationContext;
	}
	
	
	/**
	 * 获得观察者
	 * @return
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public List<ObserverListener> queryObserverListeners(){
		List<ObserverListener> list=new ArrayList<ObserverListener>();
		Map map=this.applicationContext.getBeansOfType(ObserverListener.class);
		for(Iterator<Map.Entry> iter=map.entrySet().iterator();iter.hasNext();){
			ObserverListener execute=(ObserverListener) iter.next().getValue();
			list.add(execute);
		}
		return list;
	}
	
	
	
	
}
